﻿@model IEnumerable<MvcJE.Core.Inet.KeyDataModel>
@{
    ViewBag.Title = "CreateMOP";
}
<h2>
    Create a Method Of Procedure</h2>
<fieldset style="font-size: 90%;">
    <legend></legend>
    @using (Ajax.BeginForm("CreateMOP", new { controller = "MopExpert", area = "Inet", id = ViewBag.MopId }, new AjaxOptions { UpdateTargetId = "mopDetails" }))
    {
        var ctr = 0;
        <table>
            @foreach (var item in Model)
            {
               
                <tr>
                    <td>
                        <input type="hidden" name="param[@ctr].Id" value="@item.Id" />
                        <input type="hidden" name="param[@ctr].UserKeyValue" value="@item.UserKeyValue" />
                        <input type="hidden" name="param[@ctr].CalculatedUserKeyValue" value="@item.CalculatedUserKeyValue"
            />
                    </td>
                    <td style="text-align: right; font-weight: bold; font-size: 110%; color: Blue">
                        <label for="@item.UniqueKey.Replace(" ", "_")">
                            @item.UniqueKey
                        </label>
                    </td>
                    <td>
                        @if (item.IsTextArea)
                        { <textarea name="param[@ctr].InputValue" style="width:300px; height:80px"></textarea>
                        }
                        else
                        {
                            <input type="text" name="param[@ctr].InputValue" value="@item.InputValue" />
                        }
                    </td>
                </tr>
                        ctr++;
            }
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                    <input type="submit" name="submit" value="Create MOP" />
                </td>
            </tr>
        </table>
    }
</fieldset>
<hr />
<h1>
    Detailed MOP</h1>
<div style="float: right">
    <a href="javascript:void(0)" id="saveButton" title="Save this MOP to a file.">Save To
        file</a> | <a href="javascript:void(0)" class="clickToDialog" data-title="Template" data-source-url="/Inet/MopModule/Display/@ViewBag.MopId" data-width="750" data-heigh="600">
            View Template</a> | @Html.ActionLink("Edit", "FullEdit", new { controller = "MopModule", area = "Inet", id = ViewBag.MopId })
</div>
<div id="postMessage">
</div>
<div id="mopDetails">
</div>
<script type="text/javascript">
//<![CDATA[
    jQuery(document).ready(function () {

        $('#saveButton').live("click", function () {
            var t = $('#mopTitle').text();
            var m = $('#mopDetails').html();
            $.post("/inet/mopexpert/savemop", { title: t, mop: m },
            function (data) {
                $('#postMessage').html(data);
            });
        });

        //==================
        // end of document
    });

//]]>
</script>
